package com.zzjson.serial;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2020 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson.serial</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2020年02月19日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class SocketServerProvider {
	public static void main(String[] args) {
		ServerSocket serverSocket = null;
		InputStream inputStream = null;
		try {
			serverSocket = new ServerSocket(8080);
			Socket accept = serverSocket.accept();
			inputStream = accept.getInputStream();
			ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
			try {
				User u = (User) objectInputStream.readObject();
				System.out.println(u);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if (serverSocket != null) {

				try {
					serverSocket.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}


	}

}
